1
|
|
|
/*jslint |
2
|
|
|
indent: 4 |
3
|
|
|
*/ |
4
|
|
|
|
5
|
|
|
/*global |
6
|
|
|
$, document, gapi, setTimeout, |
7
|
|
|
CDDA, Cookies, Coordinates, Freifunk, Hillshading, NPA, Okapi, Sidebar, |
8
|
|
|
DownloadGPX, Geolocation, |
9
|
|
|
showMulticoordinatesDialog, Markers, get_cookie_string |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
///* boundaries layer */ |
13
|
|
|
//function toggleBoundaries(t) |
14
|
|
|
//{ |
15
|
|
|
// Cookies.set('boundaries', t ? "1" : "0", {expires:30}); |
16
|
|
|
// |
17
|
|
|
// if ($('#boundaries').is(':checked') != t) |
18
|
|
|
// { |
19
|
|
|
// $('#boundaries').attr('checked', t); |
20
|
|
|
// } |
21
|
|
|
// |
22
|
|
|
// if( boundariesLayerShown == t ) return; |
23
|
|
|
// boundariesLayerShown = t; |
24
|
|
|
// |
25
|
|
|
// if (t) { |
26
|
|
|
// map.overlayMapTypes.push(boundariesLayer); |
27
|
|
|
// } else { |
28
|
|
|
// map.overlayMapTypes.removeAt(map.overlayMapTypes.indexOf(boundariesLayer)); |
29
|
|
|
// } |
30
|
|
|
//} |
31
|
|
|
// |
32
|
|
|
//function restoreBoundaries(defaultValue) |
33
|
|
|
//{ |
34
|
|
|
// var state = get_cookie_string("boundaries", "invalid"); |
35
|
|
|
// |
36
|
|
|
// if (state == "0") |
37
|
|
|
// { |
38
|
|
|
// toggleBoundaries(false); |
39
|
|
|
// } |
40
|
|
|
// else if (state == "1") |
41
|
|
|
// { |
42
|
|
|
// toggleBoundaries(true); |
43
|
|
|
// } |
44
|
|
|
// else |
45
|
|
|
// { |
46
|
|
|
// toggleBoundaries(defaultValue); |
47
|
|
|
// } |
48
|
|
|
//} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/* coordinate format */ |
52
|
|
|
function setCoordinatesFormat(t) { |
53
|
|
|
'use strict'; |
54
|
|
|
|
55
|
|
|
Cookies.set('coordinatesFormat', t, {expires: 30}); |
56
|
|
|
|
57
|
|
|
if ($('#coordinatesFormat').val() !== t) { |
58
|
|
|
$('#coordinatesFormat').val(t); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
Coordinates.setFormat(t); |
62
|
|
|
Markers.update(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
function restoreCoordinatesFormat(defaultValue) { |
67
|
|
|
'use strict'; |
68
|
|
|
|
69
|
|
|
var t = get_cookie_string("coordinatesFormat", "DM"); |
70
|
|
|
|
71
|
|
|
if (t === "DM" || t === "DMS" || t === "D") { |
72
|
|
|
setCoordinatesFormat(t); |
73
|
|
|
} else { |
74
|
|
|
setCoordinatesFormat(defaultValue); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/* info dialog */ |
80
|
|
|
function showInfoDialog() { |
81
|
|
|
'use strict'; |
82
|
|
|
|
83
|
|
|
$('#dlgInfoAjax').modal({show: true, backdrop: "static", keyboard: true}); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/* alert dialog */ |
88
|
|
|
function showAlert(title, msg) { |
89
|
|
|
'use strict'; |
90
|
|
|
|
91
|
|
|
$("#dlgAlertHeader").html(title); |
92
|
|
|
$("#dlgAlertMessage").html(msg); |
93
|
|
|
$("#dlgAlert").modal({show: true, backdrop: "static", keyboard: true}); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
/* projection dialog */ |
98
|
|
|
function showProjectionDialog(callback) { |
99
|
|
|
'use strict'; |
100
|
|
|
|
101
|
|
|
$('#projectionDialogOk').off('click'); |
102
|
|
|
$('#projectionDialogOk').click(function () { |
103
|
|
|
$('body').removeClass('modal-open'); |
104
|
|
|
$('.modal-backdrop').remove(); |
105
|
|
|
$('#projectionDialog').modal('hide'); |
106
|
|
|
if (callback) { |
107
|
|
|
setTimeout(function () { |
108
|
|
|
callback($("#projectionBearing").val(), $("#projectionDistance").val()); |
109
|
|
|
}, 10); |
110
|
|
|
} |
111
|
|
|
}); |
112
|
|
|
$("#projectionDialog").modal({show: true, backdrop: "static", keyboard: true}); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
/* permalink dialog */ |
117
|
|
|
function showLinkDialog(linkUrl) { |
118
|
|
|
'use strict'; |
119
|
|
|
|
120
|
|
|
$('#linkDialogLink').val(linkUrl); |
121
|
|
|
$('#linkDialog').modal({show: true, backdrop: "static", keyboard: true}); |
122
|
|
|
$('#linkDialogLink').select(); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
|
126
|
|
|
function linkDialogShortenLink() { |
127
|
|
|
'use strict'; |
128
|
|
|
|
129
|
|
|
var longUrl = $('#linkDialogLink').val(); |
130
|
|
|
gapi.client.setApiKey('AIzaSyC_KjqwiB6tKCcrq2aa8B3z-c7wNN8CTA0'); |
131
|
|
|
gapi.client.load('urlshortener', 'v1', function () { |
132
|
|
|
var request = gapi.client.urlshortener.url.insert({resource: {longUrl: longUrl}}); |
133
|
|
|
request.execute(function (resp) { |
134
|
|
|
if (resp.error) { |
135
|
|
|
$('#linkDialogError').html('Error: ' + resp.error.message); |
136
|
|
|
} else { |
137
|
|
|
$('#linkDialogLink').val(resp.id); |
138
|
|
|
$('#linkDialogLink').select(); |
139
|
|
|
} |
140
|
|
|
}); |
141
|
|
|
}); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
//function showHillshadingDialog() |
145
|
|
|
//{ |
146
|
|
|
// $('#dialogHillshading').modal({show : true, backdrop: "static", keyboard: true}); |
147
|
|
|
//} |
148
|
|
|
|
149
|
|
|
//function showBoundariesDialog() |
150
|
|
|
//{ |
151
|
|
|
// $('#dialogBoundaries').modal({show : true, backdrop: "static", keyboard: true}); |
152
|
|
|
//} |
153
|
|
|
|
154
|
|
|
|
155
|
|
|
/* setup button events */ |
156
|
|
|
$(document).ready(function () { |
157
|
|
|
'use strict'; |
158
|
|
|
|
159
|
|
|
$("#sidebartoggle").click(function () { |
160
|
|
|
if ($('#sidebar').is(':visible')) { |
161
|
|
|
Sidebar.hide(); |
162
|
|
|
} else { |
163
|
|
|
Sidebar.show(); |
164
|
|
|
} |
165
|
|
|
}); |
166
|
|
|
$('#buttonWhereAmI').click(function () { |
167
|
|
|
Geolocation.whereAmI(); |
168
|
|
|
}); |
169
|
|
|
$("#hillshading").click(function () { |
170
|
|
|
Hillshading.toggle($('#hillshading').is(':checked')); |
171
|
|
|
}); |
172
|
|
|
//$("#boundaries").click(function () { toggleBoundaries($('#boundaries').is(':checked')); }); |
173
|
|
|
$("#npa").click(function () { |
174
|
|
|
NPA.toggle($('#npa').is(':checked')); |
175
|
|
|
}); |
176
|
|
|
$("#cdda").click(function () { |
177
|
|
|
CDDA.toggle($('#cdda').is(':checked')); |
178
|
|
|
}); |
179
|
|
|
$("#geocaches").click(function () { |
180
|
|
|
Okapi.toggle($('#geocaches').is(':checked')); |
181
|
|
|
}); |
182
|
|
|
$('#coordinatesFormat').change(function () { |
183
|
|
|
setCoordinatesFormat($('#coordinatesFormat').val()); |
184
|
|
|
}); |
185
|
|
|
$("#freifunk").click(function () { |
186
|
|
|
Freifunk.toggle($('#freifunk').is(':checked')); |
187
|
|
|
}); |
188
|
|
|
$("#buttonUploadGPX").click(function (e) { |
189
|
|
|
$("#buttonUploadGPXinput").click(); |
190
|
|
|
e.preventDefault(); |
191
|
|
|
}); |
192
|
|
|
$("#buttonExportGPX").click(function () { |
193
|
|
|
DownloadGPX.initiateDownload(); |
194
|
|
|
}); |
195
|
|
|
$("#buttonMulticoordinates").click(function () { |
196
|
|
|
showMulticoordinatesDialog(); |
197
|
|
|
}); |
198
|
|
|
}); |
199
|
|
|
|